﻿function ShowAdd() {
    $('#addModal').modal('show');
    InitPaging();

    $('#txtAddPertanyaan').keydown(function (e) {
        if (e.keyCode === 13 && !e.shiftKey) {
            e.preventDefault();
        }
    });

    $('#txtAddPilihanJawaban1').keydown(function (e) {
        if (e.keyCode === 13 && !e.shiftKey) {
            e.preventDefault();
        }
    });

    $('#txtAddPilihanJawaban2').keydown(function (e) {
        if (e.keyCode === 13 && !e.shiftKey) {
            e.preventDefault();
        }
    });

    $('#txtAddPilihanJawaban3').keydown(function (e) {
        if (e.keyCode === 13 && !e.shiftKey) {
            e.preventDefault();
        }
    });

    $('#txtAddPilihanJawaban4').keydown(function (e) {
        if (e.keyCode === 13 && !e.shiftKey) {
            e.preventDefault();
        }
    });

    $('#btAddPertanyaan').click(function () {
        if (($('#txtAddPertanyaan').val().length == 0)
            || ($('#txtAddPilihanJawaban1').val().length == 0)
            || ($('#txtAddPilihanJawaban2').val().length == 0)
            || ($('#txtAddPilihanJawaban3').val().length == 0)
            || ($('#txtAddPilihanJawaban4').val().length == 0)) {
            return false;
        }
    });
}

function ShowEdit() {
    $('#editModal').modal('show');
    InitPaging();

    $('#txtEditPertanyaan').keydown(function (e) {
        if (e.keyCode === 13 && !e.shiftKey) {
            e.preventDefault();
        }
    });

    $('#txtEditPilihanJawaban1').keydown(function (e) {
        if (e.keyCode === 13 && !e.shiftKey) {
            e.preventDefault();
        }
    });

    $('#txtEditPilihanJawaban2').keydown(function (e) {
        if (e.keyCode === 13 && !e.shiftKey) {
            e.preventDefault();
        }
    });

    $('#txtEditPilihanJawaban3').keydown(function (e) {
        if (e.keyCode === 13 && !e.shiftKey) {
            e.preventDefault();
        }
    });

    $('#txtEditPilihanJawaban4').keydown(function (e) {
        if (e.keyCode === 13 && !e.shiftKey) {
            e.preventDefault();
        }
    });

    $('#btEditPertanyaan').click(function () {
        if (($('#txtEditRekomendasi').val().length == 0)
            || ($('#txtEditPilihanJawaban1').val().length == 0)
            || ($('#txtEditPilihanJawaban2').val().length == 0)
            || ($('#txtEditPilihanJawaban3').val().length == 0)
            || ($('#txtEditPilihanJawaban4').val().length == 0)) {
            return false;
        }
    });
}

function ShowDelete() {
    $('#deleteModal').modal('show');
    InitPaging();
}

function ShowDetail() {
    $('#detailModal').modal('show');
    InitPaging();
}

function SuccessAdd() {
    $('#addModal').modal('hide');
    InitPaging();
}

function SuccessEdit() {
    $('#editModal').modal('hide');
    InitPaging();
}

function SuccessDelete() {
    $('#deleteModal').modal('hide');
    InitPaging();
}